﻿// MyLogEx.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include "CLogBatchCreater.h"
#include "CXDTFileFinder.h"
#include "CTableCreater.h"
#include "CLogWriterServer.h"
#include "CUpdateTable.h"
#include "CTableConfigure.h"
#include "CLogDatabase.h"

#include <boost/filesystem.hpp>

int main()
{
	CXDTFileFinder XDTFileFinder;
	XDTFileFinder.addFindPath(boost::filesystem::current_path().string());
	XDTFileFinder.findXDTFiles();
	std::vector<CXDTFile> xdtFiles = XDTFileFinder.getFindPaths();

	CTableManager tableManager;
	CLogDatabaseMgr databaseMgr;

	for ( auto xdtFile : xdtFiles)
	{
		CTableCreater tableCreator(&tableManager, &databaseMgr);
		CTableBasePtr tablePtr = tableCreator.CreateTable(xdtFile);
	}

	int nRet = databaseMgr.InitAllDatabases();
	nRet = tableManager.InitAllTables();


	CLogWriterServer logWriter;
	logWriter.setTableManager(&tableManager);
	std::string msg = R"(
		base_count_log:{ "records":[{"key":"userName11", "value":"maguojun11111","userName":"aa1111ahahahah"}] }
	)";

	logWriter.WriteLog(msg);


	std::string updatemsg = R"(
		base_over_log:{ "records":[
			{"userName":"userName11", "pwd":"maguojun11111"},
			{"userName":"maguojun", "pwd":"123"}
] }
	)";


	logWriter.WriteLog(updatemsg);


	return 0;
}
